package com.CST.controller.ys;
import com.CST.common.api.ResultObject;
import com.CST.dto.ys.AppealDTO;
import com.CST.dto.ys.DetailDTO;
import com.CST.dto.ys.YsDetailDTO;
import com.CST.service.ys.YsAccountDetailService;
import com.CST.service.ys.YsAppealRecordService;

import com.CST.vo.ys.AccountDetailVO;
import com.CST.vo.ys.YsAccountDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author qtx
 * @since 2023-04-21
 */
@RestController
@RequestMapping("/ysAccountDetail")
@Api(tags = "业务预算执行明细")
public class YsAccountDetailController {

    private final YsAccountDetailService service;
    private final YsAppealRecordService recordService;

    public YsAccountDetailController(YsAccountDetailService service, YsAppealRecordService recordService) {
        this.service = service;
        this.recordService = recordService;
    }

    @ApiOperation("分页业务预算执行明细查询")
    @PostMapping("/listBudgetInfo")
    public ResultObject<YsAccountDetailVO> listBudgetInfo(@RequestBody YsDetailDTO dto,HttpServletRequest res) {
        return ResultObject.success(service.listBudgetInfo(dto,res));
    }

    @ApiOperation("申诉回显，查询业务预算执行明细")
    @PostMapping("/get_obj")
    public ResultObject<AccountDetailVO> getAccountByNum(@RequestBody DetailDTO params) {
        return ResultObject.success(service.getAccountById(params.getId()));
    }

    @ApiOperation("添加申诉")
    @PostMapping("/add")
    public ResultObject<Integer> addAppeal(@RequestBody AppealDTO dto, HttpServletRequest request) throws IOException {
        dto.setSource(1);
        return ResultObject.success(recordService.addAppeal(dto,request));
    }

    @ApiOperation("业务预算执行明细导出")
    @PostMapping("/exportBusinessBudgetList")
    public ResultObject<String> exportBusinessBudgetList(@RequestBody YsDetailDTO dto, HttpServletResponse response){
        return ResultObject.success(service.exportBusinessBudgetList(dto,response));
    }

}
